package com.bdqn.qnnews.user.controller.v1;

import com.bdqn.qnnews.common.base.PageResult;
import com.bdqn.qnnews.common.base.R;
import com.bdqn.qnnews.common.constants.AdminConstants;
import com.bdqn.qnnews.user.entity.ApUserRealname;
import com.bdqn.qnnews.user.service.ApUserRealnameService;
import com.bdqn.qnnews.user.vo.AuthVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xlz
 * @since 2023-12-19
 * @description APP实名认证信息表
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/auth")
@Tag(name = "APP实名认证信息表控制器类",
        description = "ApUserRealnameController APP实名认证信息表 后端数据接口")
public class ApUserRealnameController {
    @Autowired
    private ApUserRealnameService apUserRealnameService;

    /**
     * 分页查询
     * @param vo APP实名认证信息列表查询参数
     * @return R
     */
    @Operation(summary = "分页查询", description = "分页查询")
    @PostMapping("/list")
    public PageResult<List<ApUserRealname>> getApUserRealnamePage(@RequestBody AuthVo vo) {
        return apUserRealnameService.findList(vo);
    }

    /**
     * 实名认证通过回调
     * @param vo 认证参数
     * @return
     */
    @Operation(summary = "实名认证通过")
    @PostMapping("/authPass")
    public R<String> authPass(@RequestBody AuthVo vo) {
        return apUserRealnameService.updateStatusById(vo, AdminConstants.PASS_AUTH);
    }

    /**
     * 实名认证失败
     * @param vo 认证参数
     * @return
     */
    @Operation(summary = "实名认证失败")
    @PostMapping("/authFail")
    public R<String> authFail(@RequestBody AuthVo vo) {
        return apUserRealnameService.updateStatusById(vo, AdminConstants.FAIL_AUTH);
    }

}
